package nowcoder.interview;

import java.util.ArrayList;
import java.util.List;

class Solution1 {
    public static void main(String[] args) {
        System.out.println((int)'A');
        System.out.println((int) 'z'-'a');
    }
    public String[] permutation(String S) {
        List<String> result = new ArrayList<>();
        char[] a = S.toCharArray();
        dfs(a, 0, result);
        int size = result.size();
        String[] arr_result = new String[size];
        for (int i = 0; i < size; i++) {
            arr_result[i] = result.get(i);
        }
        return arr_result;



    }
    public void dfs(char[] a, int start, List<String> result) {
        if (start == a.length) {
            result.add(new String(a));
        }
        boolean[] used = new boolean[26];
        for (int i = start; i < a.length; i++) {
            int trueIndex = a[i] < 'a' ? a[i] - 'A' + 26 : a[i] - 'a';
            if (used[trueIndex]) {
                continue;
            }
            used[trueIndex] = true;
            swap(a, start, i);
            dfs(a, start + 1, result);
            swap(a, start, i);
        }

    }
    public void swap(char[] a, int start, int i) {
        char temp = a[i];
        a[i] = a[start];
        a[start] = temp;
    }
}